package http_servlet_request;

import com.fasterxml.jackson.databind.ObjectMapper;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Creared with IntelliJ IDEA.
 * Description:
 * User:yxd
 * Date:2022-05-31
 * Time:22:20
 */
class A{
    public int aa;
    public int bb;
}
@WebServlet("/testPost2")
public class testPostServlet2 extends HttpServlet {
    ObjectMapper objectMapper = new ObjectMapper();
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //
        A a = objectMapper.readValue(req.getInputStream(),A.class);
        resp.getWriter().write("aa:" + a.aa + ",bb:" + a.bb);
    }
}
